package org.lyc.dp;

/**
 * 将数字变成0的操作次数
 * https://www.bilibili.com/video/BV1aa411f7uT?p=4&spm_id_from=pageDriver&vd_source=65f5ad03ccd998407c9d802ca94f29fd
 * 给定一个非负整数num,求将其变为0所需要的步数. 如果当前数字是偶数, 则将其除以2; 若是奇数, 则减1
 *
 * @author Liu Yicong
 * @date 2024/1/31
 */
public class BStepsToZero {
	private static int num = 8;

	public static void main(String[] args) {
		int count = 0;
		while (num != 0) {
			if (num % 2 == 0) {
				num = num / 2;
			} else {
				num -= 1;
			}
			count++;
		}
		System.out.println(count);
	}
}
